<!DOCTYPE html>





<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico?v=7.4.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico?v=7.4.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico?v=7.4.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.4.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.4.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.4.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false,"dimmer":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.json',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="1. 域名概念1.1 二级域名二级域名是指顶级域名之下的域名, 见下面的例子:  .com 顶级域名 liuvv.com 一级域名(你花钱申请的) www.liuvv.com 二级域名 blog.liuvv.com 二级域名 依次类推…      有几点需要注意下:  www.liuvv.com是属于二级域名,不过一般我们把这个域名配置指向一级域名访问. www.liuvv.com/news这种形">
<meta name="keywords" content="nginx">
<meta property="og:type" content="article">
<meta property="og:title" content="nginx泛域名解析">
<meta property="og:url" content="https://unix2dos.github.io/p/d039.html">
<meta property="og:site_name" content="Levon&#39;s Blog">
<meta property="og:description" content="1. 域名概念1.1 二级域名二级域名是指顶级域名之下的域名, 见下面的例子:  .com 顶级域名 liuvv.com 一级域名(你花钱申请的) www.liuvv.com 二级域名 blog.liuvv.com 二级域名 依次类推…      有几点需要注意下:  www.liuvv.com是属于二级域名,不过一般我们把这个域名配置指向一级域名访问. www.liuvv.com/news这种形">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://unix2dos.github.io/p/d039/5.png">
<meta property="og:image" content="https://unix2dos.github.io/p/d039/2.png">
<meta property="og:image" content="https://unix2dos.github.io/p/d039/3.png">
<meta property="og:image" content="https://unix2dos.github.io/p/d039/4.png">
<meta property="og:image" content="https://unix2dos.github.io/p/d039/6.png">
<meta property="og:updated_time" content="2019-09-27T15:36:51.176Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="nginx泛域名解析">
<meta name="twitter:description" content="1. 域名概念1.1 二级域名二级域名是指顶级域名之下的域名, 见下面的例子:  .com 顶级域名 liuvv.com 一级域名(你花钱申请的) www.liuvv.com 二级域名 blog.liuvv.com 二级域名 依次类推…      有几点需要注意下:  www.liuvv.com是属于二级域名,不过一般我们把这个域名配置指向一级域名访问. www.liuvv.com/news这种形">
<meta name="twitter:image" content="https://unix2dos.github.io/p/d039/5.png">
  <link rel="canonical" href="https://unix2dos.github.io/p/d039">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>nginx泛域名解析 | Levon's Blog</title>
  








  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">
  <div class="container use-motion">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Levon's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">微信:  L6241425</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>时光</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
      <article itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block post">
    <link itemprop="mainEntityOfPage" href="https://unix2dos.github.io/p/d039.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Levon">
      <meta itemprop="description" content="Never Give Up">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Levon's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">nginx泛域名解析

          
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-07-06 11:43:46" itemprop="dateCreated datePublished" datetime="2019-07-06T11:43:46+08:00">2019-07-06</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-09-27 23:36:51" itemprop="dateModified" datetime="2019-09-27T23:36:51+08:00">2019-09-27</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/2-linux系统/" itemprop="url" rel="index"><span itemprop="name">2-linux系统</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/2-linux系统/nginx/" itemprop="url" rel="index"><span itemprop="name">nginx</span></a></span>

                
                
              
            </span>
          

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
        
      
      <span class="post-meta-item-text">Disqus：</span>
    
    <a title="disqus" href="/p/d039.html#comments" itemprop="discussionUrl"><span class="post-comments-count disqus-comment-count" data-disqus-identifier="p/d039.html" itemprop="commentCount"></span></a>
  </span>
  
  
          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span>2.7k</span>
            </span>
          
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span>2 分钟</span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="1-域名概念"><a href="#1-域名概念" class="headerlink" title="1. 域名概念"></a>1. 域名概念</h3><h5 id="1-1-二级域名"><a href="#1-1-二级域名" class="headerlink" title="1.1 二级域名"></a>1.1 二级域名</h5><p>二级域名是指顶级域名之下的域名, 见下面的例子:</p>
<ul>
<li>.com 顶级域名<ul>
<li>liuvv.com 一级域名(你花钱申请的)<ul>
<li><a href="http://www.liuvv.com" target="_blank" rel="noopener">www.liuvv.com</a> 二级域名</li>
<li>blog.liuvv.com 二级域名</li>
<li>依次类推…</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>有几点需要注意下:</p>
<ol>
<li><a href="http://www.liuvv.com是属于二级域名,不过一般我们把这个域名配置指向一级域名访问" target="_blank" rel="noopener">www.liuvv.com是属于二级域名,不过一般我们把这个域名配置指向一级域名访问</a>.</li>
<li><a href="http://www.liuvv.com/news这种形式一般称之为网站的子页面子目录等,并不是二级域名" target="_blank" rel="noopener">www.liuvv.com/news这种形式一般称之为网站的子页面子目录等,并不是二级域名</a>.</li>
<li>另外类似.com.cn, .net.cn, .org.cn这种称之为二级域.</li>
</ol>
<h5 id="1-2-域名泛解析"><a href="#1-2-域名泛解析" class="headerlink" title="1.2 域名泛解析"></a>1.2 域名泛解析</h5><p>我们的目的是实现访问二级域名后转发请求.首先要实现的是二级域名的配置,一般使用Nginx泛解析来处理. 泛解析即利用通配符*来做次级域名以实现所有的次级域名均指向同一IP地址。</p>
<p>泛解析的用途有:</p>
<ol>
<li>可以让域名支持无限的子域名(这也是泛域名解析最大的用途)。</li>
<li>防止用户错误输入导致的网站不能访问的问题。</li>
<li>可以让直接输入网址登陆网站的用户输入简洁的网址即可访问网站。</li>
</ol>
<a id="more"></a>

<h5 id="1-3-域名类型"><a href="#1-3-域名类型" class="headerlink" title="1.3 域名类型"></a>1.3 域名类型</h5><p><img src="/p/d039/5.png" alt="1"></p>
<ul>
<li><p>无论记录类型为啥, 主机记录都填写 xxxxx.liuvv.com</p>
</li>
<li><p>主机记录就是域名前缀，常见用法有：</p>
<ul>
<li>www：解析后的域名为 <code>www.liuvv.com</code></li>
<li>@：直接解析主域名 <code>liuvv.com</code></li>
<li>*：泛解析，匹配其他所有域名 <code>*.liuvv.com</code></li>
</ul>
</li>
<li><p>记录类型的含义是什么？</p>
<ul>
<li><p><strong>A 记录：</strong>地址记录，用来指定域名的 IPv4 地址（例如<code>8.8.8.8</code>），如果需要将域名指向一个 IP 地址，就需要添加 A 记录。</p>
</li>
<li><p><strong>CNAME 记录：</strong> 如果需要将域名指向另一个域名，再由另一个域名提供 IP 地址，就需要添加 CNAME 记录。(github page 就是用的这种)</p>
</li>
<li><p><strong>NS 记录：</strong>域名服务器记录，如果需要把子域名交给其他 DNS 服务商解析，就需要添加 NS 记录。</p>
</li>
<li><p><strong>AAAA 记录：</strong>用来指定主机名（或域名）对应的 IPv6 地址（例如 <code>ff06:0:0:0:0:0:0:c3</code>）记录。</p>
</li>
<li><p><strong>MX 记录：</strong>如果需要设置邮箱，让邮箱能收到邮件，就需要添加 MX 记录。</p>
</li>
<li><p><strong>TXT 记录：</strong>如果希望对域名进行标识和说明，可以使用 TXT 记录，绝大多数的 TXT 记录是用来做 SPF 记录（反垃圾邮件）。</p>
</li>
<li><p><strong>SRV 记录：</strong>SRV 记录用来标识某台服务器使用了某个服务，常见于微软系统的目录管理。主机记录处格式为：服务的名字.协议的类型。例如： <code>_sip._tcp</code>。</p>
</li>
<li><p><strong>隐、显性 URL 记录：</strong>将一个域名指向另外一个已经存在的站点，就需要添加 URL 记录。</p>
</li>
</ul>
</li>
</ul>
<ul>
<li><p>记录值如何填写？</p>
<ul>
<li><p><strong>A 记录：</strong>填写您服务器 IP，如果您不知道，请咨询您的空间商。</p>
</li>
<li><p><strong>CNAME 记录：</strong>填写空间商给您提供的域名，例如：<code>2.com</code>。</p>
</li>
<li><p><strong>MX 记录：</strong>填写您邮件服务器的 IP 地址或企业邮箱给您提供的域名，如果您不知道，请咨询您的邮件服务提供商。</p>
</li>
<li><p><strong>AAAA 记录：</strong>不常用，解析到 IPv6 的地址。</p>
</li>
<li><p><strong>NS记录：</strong>不常用，系统默认添加的两个 NS 记录请不要修改。NS 向下授权，填写 DNS 域名，例如：<code>ns3.dnsv3.com</code>。</p>
</li>
<li><p><strong>TXT 记录：</strong>记录值并没有固定的格式，不过大部分情况下，TXT 记录是用来做 SPF 反垃圾邮件的。最典型的 SPF 格式的 TXT 记录例子为 “<code>v=spf1 a mx ~all</code>”，表示只有这个域名的 A 记录和 MX 记录中的 IP 地址有权限使用这个域名发送邮件。</p>
</li>
<li><p><strong>SRV 记录：</strong>记录值格式为：优先级 权重 端口 主机名。例如：<code>0 5 5060 sipserver.example.com</code> 。</p>
</li>
<li><p><strong>隐、显性 URL 记录：</strong>记录值为必须为整的地址（必须带有协议、域名，可以包含端口号和资源定位符）。</p>
</li>
</ul>
</li>
<li><p>TTL如何填写</p>
<p>TTL即 Time To Live，缓存的生存时间。指地方 DNS 缓存您域名记录信息的时间，缓存失效后会再次到 DNSPod 获取记录值。我们默认的 600 秒是最常用的，不用修改。</p>
<ul>
<li><p>600（10分钟）：建议正常情况下使用 600。</p>
</li>
<li><p>60（1分钟）：如果您经常修改 IP，修改记录一分钟即可生效。长期使用 60，解析速度会略受影响。</p>
</li>
<li><p>3600（1 小时）：如果您 IP 极少变动（一年几次），建议选择 3600，解析速度快。如果要修改 IP，提前一天改为 60，即可快速生效。</p>
</li>
</ul>
</li>
</ul>
<h3 id="2-域名配置"><a href="#2-域名配置" class="headerlink" title="2. 域名配置"></a>2. 域名配置</h3><h5 id="2-1-配置泛解析"><a href="#2-1-配置泛解析" class="headerlink" title="2.1 配置泛解析"></a>2.1 配置泛解析</h5><p>去域名提供商那里先配置一个泛解析地址,记录类型为A.域名指向一个IPv4地址.主机记录设置为*.记录值填写服务器公网Ip地址.</p>
<p>配置好后稍微等待一下,然后访问这个域名.可以随意输入任何二级域名,访问到的都应该是顶级域名的内容.我这里访问结果总是Nginx的默认页面.</p>
<p><img src="/p/d039/2.png" alt="1"></p>
<h5 id="2-2-nginx-server-name"><a href="#2-2-nginx-server-name" class="headerlink" title="2.2 nginx server_name"></a>2.2 nginx server_name</h5><p>nginx http模块 server模块的 <code>server_name</code>指令主要用于配置基于名称的虚拟主机.匹配顺序不同结果不同.</p>
<p>a. 精准的server_name配置,如:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">server_name liuvv.com www.liuvv.com;</span><br></pre></td></tr></table></figure>

<p>b. 以通配符*开始的字符串:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">server_name *.liuvv.com;</span><br></pre></td></tr></table></figure>

<p>c. 以通配符*结束的字符串:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">server_name www.*;</span><br></pre></td></tr></table></figure>

<p>d. 配置正则表达式:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">server_name ~^(?.+)\.liuvv\.com$;</span><br></pre></td></tr></table></figure>

<p>匹配顺序由上至下,只要有一项匹配以后就会停止搜索.使用时要注意这个顺序</p>
<h5 id="2-3-绑定子域名到不同目录"><a href="#2-3-绑定子域名到不同目录" class="headerlink" title="2.3 绑定子域名到不同目录"></a>2.3 绑定子域名到不同目录</h5><p>通过匹配subdomain, 在下面的可以通过$subdomain这个变量获取当前子域名称。</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">server</span> &#123;</span><br><span class="line">        <span class="attribute">listen</span> <span class="number">80</span> default_server;</span><br><span class="line">        <span class="attribute">listen</span> [::]:<span class="number">80</span> default_server;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">server_name</span>  ~^(?&lt;subdomain&gt;.+)\.liuvv\.com$;</span><br><span class="line">        <span class="attribute">root</span> /home/levonfly/www/<span class="variable">$subdomain</span>;</span><br><span class="line">        <span class="attribute">index</span> index.html;</span><br><span class="line"></span><br><span class="line">        <span class="attribute">location</span> / &#123;</span><br><span class="line">                <span class="attribute">try_files</span> <span class="variable">$uri</span> <span class="variable">$uri</span>/ =<span class="number">404</span>;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><img src="/p/d039/3.png" alt="1"></p>
<p><img src="/p/d039/4.png" alt="1"></p>
<h5 id="2-4-绑定子域名到不同目录-多个配置文件"><a href="#2-4-绑定子域名到不同目录-多个配置文件" class="headerlink" title="2.4 绑定子域名到不同目录(多个配置文件)"></a>2.4 绑定子域名到不同目录(多个配置文件)</h5><p><img src="/p/d039/6.png" alt="1"></p>
<h3 id="3-参考资料"><a href="#3-参考资料" class="headerlink" title="3. 参考资料"></a>3. 参考资料</h3><ul>
<li><a href="https://www.cnblogs.com/summit7ca/p/6974215.html" target="_blank" rel="noopener">Nginx 泛解析配置请求映射到多端口实现二级域名访问</a></li>
<li><a href="http://www.ruanyifeng.com/blog/2016/06/dns.html" target="_blank" rel="noopener">http://www.ruanyifeng.com/blog/2016/06/dns.html</a></li>
<li><a href="https://cloud.tencent.com/document/product/302/3468" target="_blank" rel="noopener">https://cloud.tencent.com/document/product/302/3468</a></li>
</ul>

    </div>

    
    
    
        
      
        <div id="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作, 一个耿直的笑脸~</div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
        
      
      <div style="display: inline-block">
        <img src="/images/wechatpay.jpg" alt="Levon 微信支付">
        <p>微信支付</p>
      </div>
        
      
      <div style="display: inline-block">
        <img src="/images/alipay.jpg" alt="Levon 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/nginx/" rel="tag"># nginx</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/p/6600d67c.html" rel="next" title="iterm2_zsh配置">
                  <i class="fa fa-chevron-left"></i> iterm2_zsh配置
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/p/80b24c5f.html" rel="prev" title="nginx全局变量">
                  nginx全局变量 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    
  <div class="comments" id="comments">
    <div id="disqus_thread">
      <noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
    </div>
  </div>
  
  

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">
        
        
        
        
      

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-域名概念"><span class="nav-number">1.</span> <span class="nav-text">1. 域名概念</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#1-1-二级域名"><span class="nav-number">1.0.1.</span> <span class="nav-text">1.1 二级域名</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#1-2-域名泛解析"><span class="nav-number">1.0.2.</span> <span class="nav-text">1.2 域名泛解析</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#1-3-域名类型"><span class="nav-number">1.0.3.</span> <span class="nav-text">1.3 域名类型</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-域名配置"><span class="nav-number">2.</span> <span class="nav-text">2. 域名配置</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#2-1-配置泛解析"><span class="nav-number">2.0.1.</span> <span class="nav-text">2.1 配置泛解析</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-2-nginx-server-name"><span class="nav-number">2.0.2.</span> <span class="nav-text">2.2 nginx server_name</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-3-绑定子域名到不同目录"><span class="nav-number">2.0.3.</span> <span class="nav-text">2.3 绑定子域名到不同目录</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-4-绑定子域名到不同目录-多个配置文件"><span class="nav-number">2.0.4.</span> <span class="nav-text">2.4 绑定子域名到不同目录(多个配置文件)</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-参考资料"><span class="nav-number">3.</span> <span class="nav-text">3. 参考资料</span></a></li></ol></div>
        
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="/images/avatar.jpg"
      alt="Levon">
  <p class="site-author-name" itemprop="name">Levon</p>
  <div class="site-description" itemprop="description">Never Give Up</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">127</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        <span class="site-state-item-count">34</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        <span class="site-state-item-count">76</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/unix2dos" title="GitHub &rarr; https://github.com/unix2dos" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:levonfly@gmail.com" title="E-Mail &rarr; mailto:levonfly@gmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://twitter.com/levonfly" title="Twitter &rarr; https://twitter.com/levonfly" rel="noopener" target="_blank"><i class="fa fa-fw fa-twitter"></i>Twitter</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://weibo.com/l6241425" title="Weibo &rarr; https://weibo.com/l6241425" rel="noopener" target="_blank"><i class="fa fa-fw fa-weibo"></i>Weibo</a>
      </span>
    
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Levon</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">507k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">7:41</span>
</div>

        












        
      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js?v=3.1.0"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="/js/utils.js?v=7.4.0"></script><script src="/js/motion.js?v=7.4.0"></script>
<script src="/js/schemes/pisces.js?v=7.4.0"></script>

<script src="/js/next-boot.js?v=7.4.0"></script>



  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>








  <script src="/js/local-search.js?v=7.4.0"></script>














  

  

  

<script>
  function loadCount() {
    var d = document, s = d.createElement('script');
    s.src = 'https://levonfly.disqus.com/count.js';
    s.id = 'dsq-count-scr';
    (d.head || d.body).appendChild(s);
  }
  // defer loading until the whole page loading is completed
  window.addEventListener('load', loadCount, false);
</script>
<script>
  function disqus_config() {
    this.page.url = "https://unix2dos.github.io/p/d039.html";
    this.page.identifier = "p/d039.html";
    this.page.title = 'nginx泛域名解析';};
  function loadComments() {
    if (window.DISQUS) {
      DISQUS.reset({
        reload: true,
        config: disqus_config
      });
    } else {
      var d = document, s = d.createElement('script');
      s.src = 'https://levonfly.disqus.com/embed.js';
      s.setAttribute('data-timestamp', '' + +new Date());
      (d.head || d.body).appendChild(s);
    }
  }
    window.addEventListener('load', loadComments, false);
  
</script>

</body>
</html>
